package com.ygkj.common.distributionlock.lock;

/**
 * abstract distribution lock
 */
public abstract class AbstractLock implements  Lock{

    public void getLock() {
        if (tryLock()) {
            System.out.println("##获取lock锁的资源####");
        } else {
            waitLock();
            getLock();
        }
    }

    /**
     * try get lock
     * @return boolean true/false
     */
    public abstract boolean tryLock();

    /**
     *
     */
    public abstract void waitLock();
}
